package com.ck.demo.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class IndexController {
    @GetMapping(value = {"/","index","toLogin"})
    public String login(){
        return "index";
    }

    @GetMapping("dashboard")
    public String bash(){
        return "dashboard";
    }

    @GetMapping("error")
    public String tt(){
        return "404";
    }

    @GetMapping("list")
    public String list(){
        return "list";
    }

    @GetMapping("bash")
    public String bash(@RequestParam String name, @RequestParam String pwd,@RequestParam String cnus,Model model){
        //System.out.println(cnus+"英文名");
        //System.out.println(name+"用户名"+pwd+"密码");
        String cw="密码错误";
        if (name.equals("admin") && pwd.equals("123")){
            //System.out.println(name+"用户名");
            return "dashboard";
        }else{
            model.addAttribute("error","错误");
            System.out.println("进来了");
            return "index?lang="+cnus;
        }
    }

    @RequestMapping("/toMain")
    public String toMain(){
        return "dashboard";
    }


}
